#!/usr/bin/python
# plot_distinction.py

import numpy
from matplotlib import use as useBackend
useBackend('Agg')
import matplotlib.pyplot as ppt
#import matplotlib.colorbar as clb


def cheat111():
    '''Cheat to clear the plot.'''
    ppt.subplot(311)
    ppt.plot([0,1],[1,2])
    ppt.subplot(111)

def plot(DistMod, ExtMod, simpars):
    '''Shows a slice of GM_distinction's results.'''
    for i in simpars:
        cmd = "%s = simpars['%s']" % (i,i)
        exec cmd

    # Distance modulus
    cheat111()
    d = dlocs*PtScaled
    ppt.plot(d, DistMod)
    ppt.xlabel('Distance from Sol')
    ppt.ylabel('Distance modulus')
    ppt.title("Distance modulus vs. distance")
    plotname = outdir+'Output/DistMod.pdf'
    ppt.savefig(plotname)

    # Extinction (up to a constant)
    cheat111()
    ppt.imshow(ExtMod)
    ppt.colorbar()
    ppt.title("Extinction coefficient as a funtion of b, d")
    ppt.xlabel('b, angle out of galactic plane')
    ppt.ylabel('d, distance from Sol')
    plotname = outdir+'Output/ExtCoeffFull.pdf'
    ppt.savefig(plotname)

    ppt.hold(True)
    cheat111()
    ppt.subplot(211)
    ppt.title('Some slices of extinction')
    ppt.plot(ExtMod[0,:])
    ppt.plot(ExtMod[25,:])
    ppt.plot(ExtMod[50,:])
    ppt.plot(ExtMod[75,:])
    ppt.plot(ExtMod[99,:])
    ppt.xlabel('b, angle out of galactic plane')
    ppt.ylabel('Extn. for fixed values of d')
    ppt.subplot(212)
    ppt.plot(ExtMod[:,0])
    ppt.plot(ExtMod[:,25])
    ppt.plot(ExtMod[:,50])
    ppt.plot(ExtMod[:,75])
    ppt.plot(ExtMod[:,99])
    ppt.xlabel('d, distance from Sol')
    ppt.ylabel('Extn. for fixed values of b')
    ppt.hold(False)
    plotname = outdir+'Output/ExtCoeffSlices.pdf'
    ppt.savefig(plotname)

#    fulldistinction = 
